#pragma once


class String
{
public:
	String();												// Default Constructor
	String(const char* str);								// Conversion Constructor
	String(const String& str);								// Copy Constructor
	String(const int num);									// Int to String Conversion Constructor
	String(const unsigned int num);							// Unsigned Int to String Conversion Constructor
	String(const short num);								// Short to String Conversion Constructor
	String(const unsigned short num);						// Unsigned Short to String Conversion Constructor
	String(const long num);									// Long to String Conversion Constructor
	String(const unsigned long num);						// Unsigned Long to String Conversion Constructor
	String(const float num);								// Float to String Conversion Constructor
	String(const double num);								// Double to String Conversion Constructor
	String(const bool val);									// Bool to String Conversion Constructor
	~String();												// Destructor

public:
	String	operator=(const String& rhs);					// Assignment operator
	String	operator+(const String& rhs);					// String concatination
	String	operator+(const char rhs);						// String concatination
	char&	operator[](int index);							// Index operator

	String  operator+=(const String& rhs);
	String  operator+=(const char rhs);
	
	bool	operator==(const String& rhs) const;			// Logical equals operator
	bool	operator<(const String& rhs) const;				// Logical less than operator
	bool	operator>(const String& rhs) const;				// Logical greater than operator

public:
	void			clear();								// Clear the current string
	int				length() const;							// Length of the string
	const String&	lower();								// Make all charecters lower case
	const String&	upper();								// Make all charecters upper case
	const String&	propper();								// Make charecers "Propper" case
	const String&	reverse();								// Revers the string
	void			delChar(int index);						// Remove a charecter by an index
	void			backspace();							// Remove a charecter from the end
	String			substr(int start, int end) const;		// Return a sub string of this string

	int		getTokenCount(const String& delim) const;				// Returns the number of tokens in the string delimited by a charecter set			
	String	getToken(unsigned int i, const String& delim) const ;	// Returns a specific token (zero based index)

public:
	const char*	cstr(void) const;

	/////// Private member methods and variables /////////
private:
	int		strlen(const char* str);
	void	strcpy(char* dest, const char* src);
	void	allocate(int size);
	void	free();
private:
	char*	m_str;
	int		m_count;
};

inline String  String::operator+=(const String& rhs) { return *this = *this + rhs; }
inline String  String::operator+=(const char rhs)    { return *this = *this + rhs; }

inline String  operator+(const char* str, const String& rhs) { return String(str) + rhs; }